<template>
  <base-modal
    class="ApplyModal"
    :show="visible"
    :title="$t('component.imApplyVideoModal.title')"
    width="520px"
    @close="() => { $emit('update:visible', false) }"
  >
    <div class="container">
      <div class="introduce">
        <img src="@src/assets/img/im/video_phone.png" alt="" />
        <ul class="introduce__list">
          <li class="introduce__list-item">
            <div class="title">{{ $t('component.imApplyVideoModal.introduce[0].title') }}</div>
            <div class="desc">{{ $t('component.imApplyVideoModal.introduce[0].desc') }}</div>
          </li>
          <li class="introduce__list-item">
            <div class="title">{{ $t('component.imApplyVideoModal.introduce[1].title') }}</div>
            <div class="desc">{{ $t('component.imApplyVideoModal.introduce[1].desc') }}</div>
          </li>
          <li class="introduce__list-item">
            <div class="title">{{ $t('component.imApplyVideoModal.introduce[2].title') }}</div>
            <div class="desc">{{ $t('component.imApplyVideoModal.introduce[2].desc') }}</div>
          </li>
        </ul>
      </div>
      <div class="apply-row">
        <el-button
          class="apply-btn"
          type="primary" 
          round
          @click="handleApply"
        >{{ $t('component.imApplyVideoModal.apply') }}</el-button>
      </div>
    </div>
  </base-modal>
</template>
<script>
import { defineComponent } from 'vue'
import platform from '@src/util/platform'
import { t } from '@src/locales'
import { postPage, getRootWindow } from 'pub-bbx-utils'
import { saveValueAddedClue } from '@src/api/Clue'

export default defineComponent({
  name: 'ApplyModal',
  props: {
    visible: {
      type: Boolean,
      default: false,
    },
  },
  methods: {
    handleApply(){
      if(!sessionStorage.getItem('clueType3')){
        sessionStorage.setItem('clueType3', 'true')
        saveValueAddedClue({ type: 3 })
      }
      this.$emit('update:visible', false);
      const rootWindow = getRootWindow(window)
      if(rootWindow?.grayAuth?.exclusiveCsIM){
        postPage({
          action: 'shb.system.openChat',
          data: {},
        })
      }else {
        platform.alert(t('component.imApplyVideoModal.applySuccessTip'))
      }
    } 
  },
});
</script>
<style lang="scss">
.ApplyModal {
  .base-modal-header {
    padding: 20px 22px 10px 16px;
    text-align: center;
    background: white;
    font-size: 18px;
    font-weight: 600;
  }

  .base-modal-header-close {
    i {
      font-size: 22px;
      font-weight: bold;
    }
  }

  .introduce {
    padding: 10px 50px;
    display: flex;
    align-items: center;
    & > img {
      width: 135px;
    }
    .introduce__list {
      margin: 0;
      .introduce__list-item {
        &:not(:first-of-type) {
          margin-top: 12px;
        }
        padding: 10px 12px;
        width: 245px;
        border-radius: 8px;
        background: #f5f8f9;
        .title {
          color: #262626;
          font-size: 16px;
          font-weight: 500;
        }
        .desc {
          font-size: 12px;
          line-height: 22px;
          color: #595959;
        }
      }
    }
  }
  .apply-row {
    display: flex;
    align-items: center;
    justify-content: center;
    .apply-btn {
      margin: 20px 0 30px 0;
      min-width: 280px;
      height: 44px;
    }
  }
}
</style>
